package org.example.secondkill.controller;

import org.example.secondkill.domain.vo.OrderVO;
import org.example.secondkill.response.BaseResponse;
import org.example.secondkill.response.ResultCode;
import org.example.secondkill.service.IGoodsService;
import org.example.secondkill.service.IOrderService;
import org.example.secondkill.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private IUserService userService;

    @Autowired
    private IOrderService orderService;

    @Autowired
    private IGoodsService goodsService;

    @RequestMapping("/detail/{orderId}")
    @ResponseBody
    public BaseResponse<OrderVO> orderDetail(@PathVariable("orderId") long orderId) {
        OrderVO orderVO = orderService.getOrderByOrderId(orderId);
        if (orderVO == null) {
            return BaseResponse.error(ResultCode.ORDER_NOT_EXIST);
        }
        return BaseResponse.success(orderVO);
    }
}
